package net.hancl.modules.sys.controller;

import net.hancl.common.bean.ResultBean;
import net.hancl.modules.sys.entity.Dict;
import net.hancl.modules.sys.service.IDictService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping(value = "sys/dict")
public class DictController {

    @Autowired
    private IDictService dictService;

    @RequestMapping(value = "getByType", method = RequestMethod.GET)
    @ResponseBody
    public ResultBean getByType(HttpServletRequest request,
                                HttpServletResponse response, String type) {
        ResultBean rb = new ResultBean();

        if(StringUtils.isBlank(type)){
            return rb;
        }


        dictService.getByType(type);
        List<Dict> result = dictService.getByType(type);
        rb.setData(result);

        return rb;
    }
}
